﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using CheckLift.ViewObjects;
using CheckLift.Linq;
using CheckLift.Common.Intf;

namespace CheckLift.ViewModels
{
    public class ReportDetailsViewModel : INotifyPropertyChanged
    {
        public ReportDetailsViewObject ReportDetailView { get; set; }

        public void InitReportData(User user, IReport reportView)
        {
            ReportDetailView = new ReportDetailsViewObject();

            Guid companyId = reportView == null ? Guid.Empty : reportView.Lift.Customer.CompanyId;

            ReportDetailView.Report = reportView == null ? new Report() : reportView;

            ReportDetailView.User = user;
            ReportDetailView.Company = new CompanyData().GetCompaniesByUserId(user.Id, companyId);
            //ReportDetailView.Customer =  new CustomerData().GetCustomer(ReportDetailView.Report.Lift.CustomerId, user.Id);
            //ReportDetailView.Lift = reportId == Guid.Empty? new LiftView() : new LiftData().GetLift(ReportDetailView.Report.LiftId);
            //ReportDetailView.ServiceCompany = reportId == Guid.Empty? new ServiceCompany() :  new ServiceCompanyData().GetServiceCompany(ReportDetailView.Lift.ServiceId);
            ReportDetailView.ReportValues = new ReportDataImpl().GetReportPropertyValues(ReportDetailView.Report.Id);

        }

        public void SaveReportDetails()
        {
            
        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        
        #endregion
    }
}
